The present invention relates to a method and apparatus for detecting color in video images, and in particular to a method and apparatus for identifying pixels of a given color in a field of YUV video.
A variety of discrimination systems, operating in a range of circumstances, use color analysis as a basic tool. An example can be found in agriculture where a green area, such as a weed or other target plant, must be detected in an area of another color, such as brown soil, in order to be sprayed.
PCT/CA95/00595 (Rees) discloses a spray controller comprising a detector that generates red, green and blue color signals across a field of view. The color signals are used to generate an output control signal xe2x80x98its greenxe2x80x99 or xe2x80x98not greenxe2x80x99 for actuating a spray nozzle on detection of something deemed to be green. Two possible algorithms which determine if something is xe2x80x98greenxe2x80x99 rather than xe2x80x98not greenxe2x80x99 are described. One requires the level of green to exceed each of the red and blue components in the color signal. The second algorithm requires the green level to exceed the red level and the blue level to be less than a set value.
Other approaches in the prior art for detecting whether a pixel has a target color involve the use of a look-up table that stores a value for every combination of U and V values, where U and V represent the color difference signals produced by a video camera and define the working color space. These approaches require circuitry to support the addressing and read-back of the look-up table as well as a considerable amount of memory to store the table.
The hardware implementation of the above described approaches requires several blocks of logic circuitry, leading to increased cost and complexity of the system.
The bandwidth of the chroma signal in a standard video signal is sufficient only for determining the chrominance accurately over a span of approximately nine pixels horizontally. In other words, the maximum amount of chroma change, from red to green for example, takes approximately nine pixels in a horizontal line. If pixel 1 is red, then the closest pixel which can be green is pixel 10. The pixels between these two will have varying shades from red to green. Similarly, a signal transition from yellow to blue must pass through shades of either red or green along the transition. Thus, a device for detecting green pixels may xe2x80x9cdetectxe2x80x9d green even though only blue and yellow are present in the scene viewed by the camera.
An object of the present invention to provide a simple and reliable video imaging color detection technique that avoids the problems and disadvantages of the prior art.
According to one aspect of the invention there is provided a method of identifying a pixel of a given color in a field of YUV video by maximizing the pixel""s corresponding signal in the color region of interest of a color space, and minimizing signals in all other areas of the color space. Additionally, the color region of interest is rotated so as to be on or near one of the U and V axes of the UV color space.
An advantage of the technique of the present invention is the minimal amount of logic circuitry required for its implementation. Only one comparator is needed in addition to the circuitry already existing within a conventional video camera, the circuitry within the camera performing the axis rotation and signal gain. Another advantage of this technique is that the number of false detections of pixels of a given color due to insufficient chroma bandwidth is greatly reduced.
The invention provides methods of processing a video signal to recognize whether a pixel belongs to a region of interest of a color space. A first method comprises the steps of, for each pixel, transforming the video signal into color difference signals corresponding to a set of defining axes of the color space; minimizing the signal gain for all color difference signals except for a color difference signal defining the region of interest; establishing a threshold value representing the minimum magnitude the color difference signal defining the region of interest must have when the pixel belongs to the region of interest of the color space; and comparing the color difference signal defining the region of interest with the threshold value to determine if the pixel is in the region of interest. In a specific application useful for detecting green weeds to be sprayed in a field, the axes are a red axis and a blue axis and the region of interest is green. In this case the gains of the blue axis signal and positive red axis signal are minimized, leaving the negative red axis signal. The negative red axis signal is then compared to a threshold value to determine if it is negative enough to be considered green.
A modification of the method comprises rotating one axis signal toward the other axis. Green has a negative blue component. To take advantage of this data the blue axis signal is rotated toward the red axis before the gains are applied.
In a further embodiment the entire color space is rotated to bring the color region of interest closer to, or onto, one of the axes.
According to a further aspect of the invention there is provided an apparatus for processing a video signal to determine when a pixel belongs to a region of interest of a color space, the apparatus comprising: a transformation circuit for transforming the video signal into color difference signals corresponding to a set of defining axes of the color space; gain circuits for minimizing the signal gain of all color difference signals except for a color difference signal defining the region of interest; and a comparator responsive to at least one of the gain circuits for comparing the color difference signal defining the region of interest with a threshold value representing the minimum magnitude the color difference signal defining the region of interest must have when the pixel belongs to the region of interest, the comparator producing an output signal indicating the pixel is in the region of interest when the color difference signal defining the region of interest exceeds the threshold value. The apparatus may include a matrix for rotating the color difference signal corresponding to one axis toward the other axis.
An object of the invention is to provide an apparatus as described above in combination with at least one spray nozzle mounted on the boom of a an agricultural sprayer, and means responsive to the comparator output signal for energizing at least one spray nozzle.
An application of the present technique is in agriculture, for weed detection. A video camera mounted on the spray boom of an agricultural sprayer may detect green weeds on brown soil by identifying the green pixels in the image captured as the sprayer travels in the field. With the aid of a controller, spray may be released upon the weed, once the weed is detected.
Other advantages, objects and features of the present invention will be readily apparent to those skilled in the art upon consideration of the following detailed description of preferred embodiments and the accompanying drawings.